/*
 *   项目名称：train12306
 *   文件名称：com.xiaolon.train12306.common.interceptor.LogInterceptor
 *
 *   创建人：  ZHOU XIAO LONG
 *   创建日期：2024/12/26
 *
 */
package com.xiaolon.train12306.common.interceptor;

import cn.hutool.core.util.RandomUtil;
import jakarta.servlet.http.HttpServletRequest;
import jakarta.servlet.http.HttpServletResponse;
import org.slf4j.MDC;
import org.springframework.stereotype.Component;
import org.springframework.web.servlet.HandlerInterceptor;

/**
 * 类描述： LogInterceptor
 **/
@Component
public class LogInterceptor implements HandlerInterceptor {

    @Override
    public boolean preHandle(HttpServletRequest request, HttpServletResponse response, Object handler) throws Exception {
        // 增加日志流水号
        MDC.put("LOG_ID", System.currentTimeMillis() + RandomUtil.randomString(3));
        return true;
    }
}